/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package uimigration.mappingmodel.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import uimigration.mappingmodel.MappingActionEvent;
import uimigration.mappingmodel.MappingBehaviourEvent;
import uimigration.mappingmodel.MappingPositionProperties;
import uimigration.mappingmodel.MappingTable;
import uimigration.mappingmodel.MappingmodelPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Mapping Table</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link uimigration.mappingmodel.impl.MappingTableImpl#getName <em>Name</em>}</li>
 *   <li>{@link uimigration.mappingmodel.impl.MappingTableImpl#getActionsMapping <em>Actions Mapping</em>}</li>
 *   <li>{@link uimigration.mappingmodel.impl.MappingTableImpl#getBehaviorsMapping <em>Behaviors Mapping</em>}</li>
 *   <li>{@link uimigration.mappingmodel.impl.MappingTableImpl#getPositionsMapping <em>Positions Mapping</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MappingTableImpl extends EObjectImpl implements MappingTable {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;
	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;
	/**
	 * The cached value of the '{@link #getActionsMapping() <em>Actions Mapping</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getActionsMapping()
	 * @generated
	 * @ordered
	 */
	protected EList<MappingActionEvent> actionsMapping;
	/**
	 * The cached value of the '{@link #getBehaviorsMapping() <em>Behaviors Mapping</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBehaviorsMapping()
	 * @generated
	 * @ordered
	 */
	protected EList<MappingBehaviourEvent> behaviorsMapping;
	/**
	 * The cached value of the '{@link #getPositionsMapping() <em>Positions Mapping</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPositionsMapping()
	 * @generated
	 * @ordered
	 */
	protected EList<MappingPositionProperties> positionsMapping;
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MappingTableImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return MappingmodelPackage.Literals.MAPPING_TABLE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MappingmodelPackage.MAPPING_TABLE__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<MappingActionEvent> getActionsMapping() {
		if (actionsMapping == null) {
			actionsMapping = new EObjectContainmentEList<MappingActionEvent>(MappingActionEvent.class, this, MappingmodelPackage.MAPPING_TABLE__ACTIONS_MAPPING);
		}
		return actionsMapping;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<MappingBehaviourEvent> getBehaviorsMapping() {
		if (behaviorsMapping == null) {
			behaviorsMapping = new EObjectContainmentEList<MappingBehaviourEvent>(MappingBehaviourEvent.class, this, MappingmodelPackage.MAPPING_TABLE__BEHAVIORS_MAPPING);
		}
		return behaviorsMapping;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<MappingPositionProperties> getPositionsMapping() {
		if (positionsMapping == null) {
			positionsMapping = new EObjectContainmentEList<MappingPositionProperties>(MappingPositionProperties.class, this, MappingmodelPackage.MAPPING_TABLE__POSITIONS_MAPPING);
		}
		return positionsMapping;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MappingmodelPackage.MAPPING_TABLE__ACTIONS_MAPPING:
				return ((InternalEList<?>)getActionsMapping()).basicRemove(otherEnd, msgs);
			case MappingmodelPackage.MAPPING_TABLE__BEHAVIORS_MAPPING:
				return ((InternalEList<?>)getBehaviorsMapping()).basicRemove(otherEnd, msgs);
			case MappingmodelPackage.MAPPING_TABLE__POSITIONS_MAPPING:
				return ((InternalEList<?>)getPositionsMapping()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case MappingmodelPackage.MAPPING_TABLE__NAME:
				return getName();
			case MappingmodelPackage.MAPPING_TABLE__ACTIONS_MAPPING:
				return getActionsMapping();
			case MappingmodelPackage.MAPPING_TABLE__BEHAVIORS_MAPPING:
				return getBehaviorsMapping();
			case MappingmodelPackage.MAPPING_TABLE__POSITIONS_MAPPING:
				return getPositionsMapping();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case MappingmodelPackage.MAPPING_TABLE__NAME:
				setName((String)newValue);
				return;
			case MappingmodelPackage.MAPPING_TABLE__ACTIONS_MAPPING:
				getActionsMapping().clear();
				getActionsMapping().addAll((Collection<? extends MappingActionEvent>)newValue);
				return;
			case MappingmodelPackage.MAPPING_TABLE__BEHAVIORS_MAPPING:
				getBehaviorsMapping().clear();
				getBehaviorsMapping().addAll((Collection<? extends MappingBehaviourEvent>)newValue);
				return;
			case MappingmodelPackage.MAPPING_TABLE__POSITIONS_MAPPING:
				getPositionsMapping().clear();
				getPositionsMapping().addAll((Collection<? extends MappingPositionProperties>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MappingmodelPackage.MAPPING_TABLE__NAME:
				setName(NAME_EDEFAULT);
				return;
			case MappingmodelPackage.MAPPING_TABLE__ACTIONS_MAPPING:
				getActionsMapping().clear();
				return;
			case MappingmodelPackage.MAPPING_TABLE__BEHAVIORS_MAPPING:
				getBehaviorsMapping().clear();
				return;
			case MappingmodelPackage.MAPPING_TABLE__POSITIONS_MAPPING:
				getPositionsMapping().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MappingmodelPackage.MAPPING_TABLE__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case MappingmodelPackage.MAPPING_TABLE__ACTIONS_MAPPING:
				return actionsMapping != null && !actionsMapping.isEmpty();
			case MappingmodelPackage.MAPPING_TABLE__BEHAVIORS_MAPPING:
				return behaviorsMapping != null && !behaviorsMapping.isEmpty();
			case MappingmodelPackage.MAPPING_TABLE__POSITIONS_MAPPING:
				return positionsMapping != null && !positionsMapping.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //MappingTableImpl
